package com.wu;

import java.util.Observable;

public class ObserverDemo {

    public static void main(String[] args) {
        //构建可观察对象
        MyObservable observable = new MyObservable();
        observable.addObserver((ob,value)->{
            System.out.printf("第一个观察到的值: %s \n",value);
        });
        observable.addObserver((ob,value)->{
            System.out.printf("第二个观察到的值: %s \n",value);
        });
        observable.setChanged();
        observable.notifyObservers(101);


    }


}

class  MyObservable extends  Observable{

    @Override
    public void setChanged() {
        super.setChanged();
    }
}